package com.teradata.dashboard.ui.fragment;

import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.teradata.dashboard.R;

public class AlertFragment extends Fragment {
	
	 @Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,  
	            Bundle savedInstanceState) {  
		 	View orderLayout = inflater.inflate(R.layout.alert, container, false);
			System.out.println("kpi input");
			
			initHead();
			
			showKpiList("2222222222");
			return orderLayout; 
	    }  
	 
	 
		private void initHead() {
			final ActionBar actionBar = getActivity().getActionBar(); 
			actionBar.setDisplayShowTitleEnabled(true);
			actionBar.setDisplayShowCustomEnabled(true);
			View actionBarButtons = LayoutInflater.from(getActivity()).inflate(R.layout.head,
                    new LinearLayout(getActivity()), false);
			((TextView)actionBarButtons.findViewById(R.id.tv_head)).setText(R.string.alert);
			actionBarButtons.setOnClickListener(new OnClickListener() {//监听事件  
	            @Override
				public void onClick(View arg0) {  
	                switch (arg0.getId()) {  
	                case R.id.btn_leftTop:  
	                    break;  
	                default:  
	                    break;  
	                }  
	            }  
	        });  
			this.getActivity().getActionBar().setCustomView(actionBarButtons);
		}
		
		 private void showKpiList(String categoryId) {
				KpiListFragment fragment = new KpiListFragment();
				Bundle args = new Bundle();
				args.putString(KpiFragment.SELECTED_CATEGORY_ID, categoryId);
				fragment.setArguments(args);
				FragmentTransaction ft = getFragmentManager().beginTransaction();
				ft.replace(R.id.kpiAlertListContainer, fragment);
				ft.commit();
			}
}
